package literal;

import atom.Atom;
import sign.FormulaSign;

import java.util.Objects;

public abstract class Literal {
    Atom atom;
    boolean negated;

    public Literal(Atom atom,boolean negated){
        this.atom=atom;
        this.negated=negated;
    }

    @Override
    public String toString(){
        return (negated ? "\\neg " : "")+atom.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Literal literal = (Literal) o;
        return negated == literal.negated && Objects.equals(atom, literal.atom);
    }

    @Override
    public int hashCode() {
        return Objects.hash(atom, negated);
    }

    public Atom getAtom(){
        return this.atom;
    }

    public boolean getNegated(){
        return this.negated;
    }
}
